<template>
	<view class="box">
		<view class="header">
			{{title}}
		</view>
		<view class="list" v-for="item in list">
			<view class="li" @click="goNumber(item)">
				<view class="left">
					{{item.houseno}}
				</view>
				<view class="right">
					<image src="https://s1.ax1x.com/2022/11/26/ztawa6.jpg" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {reqhouses} from '../../utils/api.js'
	export default{
		data(){
			return{
				title:'',
				building:{},
				list:[]
			}
		},
		onLoad(option){
			console.log(option);
			this.building = JSON.parse(option.building)
			this.title = option.title
			this.gethouses()
		},
		methods:{
			async gethouses(){
				let res = await reqhouses({buildingid: this.building.id})
				console.log(res);
				if(res.errCode==10000){
					this.list = res.data.list
				}
			},
			goNumber(e){
				console.log(e);
				console.log(e.id);
				this.title += e.houseno
				this.$store.commit('house/SET_TITLE',{title:this.title,buildingid:e.id})
				// this.$store.commit('house/SET_BUILDING',{})
				uni.navigateBack({
					delta: 3,
				})
			}
		}
	}
</script>

<style lang="less">
	.header{
		width: 100%;
		height: 82rpx;
		background-color: #f0f0f0;
		padding: 0 30rpx;
		line-height: 82rpx;
	}
	.list{
		.li{
			width: 720rpx;
			height: 99rpx;
			border-bottom: 1rpx solid #f0f0f0;
			margin-left: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			
			.right{
				image{
					width: 25rpx;
					height: 25rpx;
					margin-right: 20rpx;
				}
			}
		}
	}
</style>